package db.logging;

import java.text.SimpleDateFormat;
import java.util.Date;

public class MyLogger {

	Appender appender;

	public MyLogger(Appender appender) {
		this.appender = appender;
	}

	void store(String str) {
		appender.store(getCurrentTime() + " " + str);
	}

	void store(String str, Object o) {
		String pattern = "\\{\\}";
		String replaceString = o.toString();
		this.store(str.replaceFirst(pattern, replaceString));

	}

	String getCurrentTime() {
		SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss,SSS");
		Date currentDate = new Date();
		sdf.format(currentDate);
		return sdf.format(currentDate);
	}

	public void info(String arg0) {
		store("INFO " + arg0);
	}

	public void info(String arg0, Object arg1) {
		store("INFO " + arg0, arg1);
	}

}
